package com.dlc.garbagerecyclebox.bean;

import com.dlc.commonbiz.base.serialport.DataPack;

/**
 * @author :      fangbingran
 * @aescription : 心跳数据
 * @date :        2019/07/30  20:13
 */
public class HeartBeatBean implements Cloneable{
    /**
     * 投递信息
     */
    private DeliveryInfoBean deliveryInfoBean;
    /**
     * 回收信息
     */
    private RecyclingInfoBean recyclingInfoBean;
    /**
     * 管理信息
     */
    private ManageMaintainInfoBean manageMaintainInfoBean;
    /**
     * 处理其他情况
     */
    private DeviceInfoBean deviceInfoBean;

    public DeliveryInfoBean getDeliveryInfoBean() {
        return deliveryInfoBean;
    }

    public void setDeliveryInfoBean(DeliveryInfoBean deliveryInfoBean) {
        this.deliveryInfoBean = deliveryInfoBean;
    }

    public RecyclingInfoBean getRecyclingInfoBean() {
        return recyclingInfoBean;
    }

    public void setRecyclingInfoBean(RecyclingInfoBean recyclingInfoBean) {
        this.recyclingInfoBean = recyclingInfoBean;
    }

    public ManageMaintainInfoBean getManageMaintainInfoBean() {
        return manageMaintainInfoBean;
    }

    public void setManageMaintainInfoBean(ManageMaintainInfoBean manageMaintainInfoBean) {
        this.manageMaintainInfoBean = manageMaintainInfoBean;
    }

    @Override
    public String toString() {
        return "HeartBeatBean{" + "deliveryInfoBean=" + (deliveryInfoBean != null ? deliveryInfoBean.toString() : "") + ", recyclingInfoBean=" + (
            recyclingInfoBean != null ? recyclingInfoBean.toString() : "") + ", manageMaintainInfoBean=" + (manageMaintainInfoBean != null
            ? manageMaintainInfoBean.toString() : "") + ", deviceInfoBean=" + (deviceInfoBean != null ? deviceInfoBean.toString() : "") + "," + (
            dataPack != null ? dataPack.toString() : "") + '}';
    }

    private DataPack dataPack;

    public void setDataPack(DataPack dataPack) {
        this.dataPack = dataPack;
    }

    public DeviceInfoBean.SensorStatusBean getSensorStatusBean() {
        if (manageMaintainInfoBean != null) {
            return manageMaintainInfoBean.getSensorStatusBean();
        }
        if (deliveryInfoBean != null) {
            return deliveryInfoBean.getSensorStatusBean();
        }
        if (recyclingInfoBean != null) {
            return recyclingInfoBean.getSensorStatusBean();
        }
        if (deviceInfoBean != null) {
            return deviceInfoBean.getSensorStatusBean();
        }
        return null;
    }

    public DeviceInfoBean.FaultCodeBean getFaultCodeBean() {
        if (manageMaintainInfoBean != null) {
            return manageMaintainInfoBean.getFaultCodeBean();
        }
        if (deliveryInfoBean != null) {
            return deliveryInfoBean.getFaultCodeBean();
        }
        if (recyclingInfoBean != null) {
            return recyclingInfoBean.getFaultCodeBean();
        }
        if (deviceInfoBean != null) {
            return deviceInfoBean.getFaultCodeBean();
        }
        return null;
    }

    public void setFaultCodeBean(DeviceInfoBean.FaultCodeBean faultCodeBean) {
        if (manageMaintainInfoBean != null) {
            manageMaintainInfoBean.setFaultCodeBean(faultCodeBean);
        }
        if (deliveryInfoBean != null) {
            deliveryInfoBean.setFaultCodeBean(faultCodeBean);
        }
        if (recyclingInfoBean != null) {
            recyclingInfoBean.setFaultCodeBean(faultCodeBean);
        }
        if (deviceInfoBean != null) {
            deviceInfoBean.setFaultCodeBean(faultCodeBean);
        }
    }

    public int getDeviceAddress() {
        if (manageMaintainInfoBean != null) {
            return manageMaintainInfoBean.getDeviceAddress();
        }
        if (deliveryInfoBean != null) {
            return deliveryInfoBean.getDeviceAddress();
        }
        if (recyclingInfoBean != null) {
            return recyclingInfoBean.getDeviceAddress();
        }
        if (deviceInfoBean != null) {
            return deviceInfoBean.getDeviceAddress();
        }
        return 0;
    }

    public DeviceInfoBean getDeviceInfoBean() {
        return deviceInfoBean;
    }

    public void setDeviceInfoBean(DeviceInfoBean deviceInfoBean) {
        this.deviceInfoBean = deviceInfoBean;
    }

    public DataPack getDataPack() {
        return dataPack;
    }
    @Override
    public HeartBeatBean clone() {
        HeartBeatBean heartBeatBean = null;
        try {
            heartBeatBean = (HeartBeatBean) super.clone();
            if (deliveryInfoBean != null) {
                heartBeatBean.setDeliveryInfoBean(deliveryInfoBean.clone());
            }
            if (recyclingInfoBean != null) {
                heartBeatBean.setRecyclingInfoBean(recyclingInfoBean.clone());
            }
            if (manageMaintainInfoBean != null) {
                heartBeatBean.setManageMaintainInfoBean(manageMaintainInfoBean.clone());
            }
            if (deviceInfoBean != null) {
                heartBeatBean.setDeviceInfoBean(deviceInfoBean.clone());
            }
            if (dataPack != null) {
                heartBeatBean.setDataPack(dataPack);
            }
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return heartBeatBean;
    }
}
